//无重复最长子串
class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        vector<int>hash(128,0);
        int left = 0, right = 0, sz = s.size(), ans=0;
        if(s.empty())
        {
            return 0;
        }
        while (right < sz) {
            char rchar=s[right];
            hash[s[right]]++;
            while (hash[s[right]]>1) {
                hash[s[left++]]--;
            }
            ans=max(ans,right-left+1);
            right++;
        }
        return ans;
    }
};
